<?php
/**
 * @version		$Id: migrator.php 25 2010-09-08 15:16:11Z joomlaworks $
 * @package		K2mart
 * @author    JoomlaWorks http://www.joomlaworks.gr
 * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
 * @license		Commercial - This code cannot be redistributed without permission from Nuevvo Webware Ltd.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

class K2martControllerMigrator extends JController {

	function display(){
		jimport('joomla.filesystem.file');
		$mainframe = &JFactory::getApplication();
		if(!JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'admin.k2.php')){
			$mainframe->enqueueMessage(JText::_('K2 was not found on your system'), 'error');
		}
		if(!JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'admin.virtuemart.php')){
			$mainframe->enqueueMessage(JText::_('Virtuemart was not found on your system'), 'error');
		}
		parent::display();
	}
	
	function import(){
		$mainframe = &JFactory::getApplication();
		JRequest::checkToken() or jexit('Invalid Token');
		$model = &$this->getModel('migrator');
		$model->import();
		$mainframe->redirect('index.php?option=com_k2mart&view=migrator', JText::_('Import completed'));
	}
	
	function cancel() {
		$mainframe = &JFactory::getApplication();
		$mainframe->redirect('index.php?option=com_k2mart');
	}

}
